<?php

/**
 *   国家和地区
*/

namespace app\api\controller;
use app\facade\Basic;
use think\Request;
use app\api\service\Region as ServiceRegion;

class Region extends BaseController
{

    /**
     *  获取国家
    */
    public function countryList()
    {
        $serviceRetrieve = new ServiceRegion();
        $result = $serviceRetrieve->getCountryList();
        return Basic::json($result);
    }
    /**
     *  获取国家
     */
    public function prefixList()
    {
        $serviceRetrieve = new ServiceRegion();
        $result = $serviceRetrieve->getMobilePrefix();
        return Basic::json($result);
    }

    /**
     *  获取国家
    */
    public function cityList(Request $request)
    {
        $param['country_id'] = $request->param('country_id',null);

        /* 验证 */
        $this->validateData($param,'Region.cityList');

        $serviceRetrieve = new ServiceRegion();
        $result = $serviceRetrieve->getCityList($param);
        return Basic::json($result);

    }

    /**
     *  获取国家和区域
    */
    public function area(Request $request)
    {
        $param['country_id'] = $request->param('country_id',null);

        /* 验证 */
        $this->validateData($param,'Region.area');

        $serviceRetrieve = new ServiceRegion();
        $result = $serviceRetrieve->area($param);
        return Basic::json($result);
    }

}